package com.treasure.service.rabbit.service;

import com.treasure.service.constant.mq.GlobalConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @Description: 
 * @version 1.0 
 * @author panxinwen 2018/11/2 16:35
 * @Copyright © 2015 | 武汉京航科技有限公司 Email:19919866605@163.com
 * */

@Service
public class SendMqService{

  @Autowired
  private SendMQ sendMQ;

  public <T> T sendMsgServiceXml(String routingKey, T obj){
    sendMQ.sendMsg(routingKey, obj, System.currentTimeMillis()+"", GlobalConstant.XML);
    return obj;
  }
  public <T> T sendMsgAndReceiveServiceXml(String routingKey, T obj){
    sendMQ.sendMsgAndReceive(routingKey, obj, System.currentTimeMillis()+"", GlobalConstant.XML,obj.getClass());
    return obj;
  }

    public <T> T sendMsgServiceJson(String routingKey, T obj){
        sendMQ.sendMsg(routingKey, obj, System.currentTimeMillis()+"", GlobalConstant.JSON);
        return obj;
    }
    public <T> T sendMsgAndReceiveServiceJson(String routingKey, T obj){
        sendMQ.sendMsgAndReceive(routingKey, obj, System.currentTimeMillis()+"", GlobalConstant.XML,obj.getClass());
        return obj;
    }
    //----
    public <T> T sendInvestMsgCRMJson(String routingKey, T obj){
        sendMQ.sendMsg(routingKey, obj, System.currentTimeMillis()+"", GlobalConstant.JSON);
        return obj;
    }

    public <T> T sendInvestStatusCRMJson(String routingKey, T obj){
        sendMQ.sendMsg(routingKey, obj, System.currentTimeMillis()+"", GlobalConstant.JSON);
        return obj;
    }

    public <T> T sendCouponStatusCRMJson(String routingKey, T obj){
        sendMQ.sendMsg(routingKey, obj, System.currentTimeMillis()+"", GlobalConstant.JSON);
        return obj;
    }

}
